package com.jobsys.job;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.log4j.Logger;
import org.quartz.JobExecutionContext;

import com.jobsys.pageprocesser.BaiPinPage;
import com.jobsys.utils.SpiderThreadPool;

import us.codecraft.webmagic.Spider;

/**
 * 百聘搜索引擎：校园招聘
 * 
 * @author
 *
 */
public class BaiPinJob extends AbsJob {
	private Logger logger = Logger.getLogger(BaiPinJob.class);

	@Override
	protected void process(JobExecutionContext context) {
		// TODO Auto-generated method stub
		logger.info("爬取百聘...");
		SimpleDateFormat st = new SimpleDateFormat("yyyyMMdd");
		String startdate = st.format(new Date());
		startdate = startdate + "_" + startdate;

		String url = String.format(
				"http://zhaopin.baidu.com/api/xzzwmidasync?query=&recruitcity=&rn=30&pn=0&sort_key=7&startdate=%s",
				startdate);
		Spider spider = Spider.create(new BaiPinPage()).addUrl(url);
		// 加入线程池管理
		SpiderThreadPool.add(this.getClass().getName(), spider);
		spider.run();
	}
}
